package com.hundsun.yr.universal.p2p.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.netstatus.NetUtils;
import com.hundsun.yr.universal.library.utils.HsStringUtils;
import com.hundsun.yr.universal.library.utils.SpannableStringBuilderUtils;
import com.hundsun.yr.universal.library.widget.HSButton;
import com.hundsun.yr.universal.p2p.bean.UserInfo;
import com.hundsun.yr.universal.p2p.config.Extras;
import com.hundsun.yr.universal.p2p.ui.activity.base.BaseActivity;

import de.greenrobot.event.EventBus;

/**
 * Created by apple on 2017/11/28.
 */

public class RechargeSuccess extends BaseActivity implements View.OnClickListener{

    private HSButton btn_look_product = null;
    private TextView tv_bank_card_num = null;
    private TextView tv_account_balance = null;
    private TextView tv_success_recharge = null;

    private String RECHAGE_AMOUNT;
    private String cardNo;

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return false;
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_recharge_success;
    }

    @Override
    protected void initViewsAndEvents() {
        btn_look_product = findView(R.id.btn_look_product);
        tv_bank_card_num = findView(R.id.tv_bank_card_num);
        tv_account_balance = findView(R.id.tv_account_balance);
        tv_success_recharge = findView(R.id.tv_success_recharge);

        tv_success_recharge.setText(getString(R.string.you_success_recharge,RECHAGE_AMOUNT));

        cardNo = sharedPreferences.getShareProf(UserInfo.BANKCARD);

        String bankName = getString(R.string._bankname, sharedPreferences.getShareProf(UserInfo.BANKCARDNAME),
                HsStringUtils.subString(cardNo, cardNo.length() - 4, cardNo.length()));
        if (cardNo.length() > 4) {
            tv_bank_card_num.setText(SpannableStringBuilderUtils.colorSpan(bankName,
                    getResources().getColor(R.color.text_cc), bankName.length() - 8, bankName.length()));
        } else {
            tv_bank_card_num.setText(bankName);
        }

        tv_account_balance.setText(getString(R.string._yuan,sharedPreferences.getShareProf(UserInfo.CAN_USE_MONEY)));

        btn_look_product.setOnClickListener(this);
        setToolbarTitle(getString(R.string.rechange_quick_success));
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
        RECHAGE_AMOUNT = extras.getString("RECHAGE_AMOUNT");
    }

    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.titleBar(R.id.common_toolbar).init();
    }

    @Override
    protected void onEveComming(EventCenter eventCenter) {

    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_look_product:
                //跳转到产品页面
                EventBus.getDefault().post(new EventCenter(Extras.RECHARGE_SUCCESS_GO_TO_PROJECT));//登陆成功通知某些页面进行数据刷新
                finish();
                break;
        }
    }
}
